<template>
  <div>
    <ul>
      <li v-for="m in messageList" :key="m.id">
        <!--路由传参，格式和query参数一致，传递变量注意要用v-bind-->
        
        <!--1.to属性的模板字符串写法-->
        <!-- <router-link :to="`/home/message/detail?id=${m.id}&title=${m.title}`">{{m.title}}</router-link>&nbsp;&nbsp; -->
        
        <!--2.to属性的对象写法，对象path属性表示路由、query表示参数-->
        <router-link :to="{
          path: '/home/message/detail',
          query: {
            id: m.id,
            title: m.title,
          }
        }">
          {{m.title}}
        </router-link>&nbsp;&nbsp;
      </li>
    </ul>
    <hr>
    <!--展示Detail组件的位置-->
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  name: "Message",
  data() {
    return {
      messageList: [
        {id: '001', title: '消息001'},
        {id: '002', title: '消息002'},
        {id: '003', title: '消息003'},
      ]
    }
  }
}
</script>

<style scoped>

</style>
